<?php
class RenwenController extends ApiController{
	public function actionMsg(){
		$listID = isset($_GET['listID'])?$_GET['listID']:'';
		if ($listID == '' ||(!is_numeric($listID))){
			echo json_encode(array(
				'code'=>0,
				'msg'=>'所传的listID格式有误或者不纯在该值)'
			));die;
		}
		$sql = "SELECT * FROM news where cate_id = 16 and id = {$listID}";
		$model = new News();
		$profile = new NewsProfile();
//		$criteria = new CDbCriteria();
//		$criteria->condition ='cate_id=16';
//		$model = $model->findAll($criteria);
		$model = $model->findAllBySql($sql);
		$arraynew = array();
		$arraynew['code']=1;
		if (!empty($model)){
			foreach ($model as $value){
				$arr =array();
				$arr['renwenImageURL'] = CHtml::value($value, 'cover');
				$arr['renwenTitle'] = CHtml::value($value, 'title');
				$id = CHtml::value($value, 'id');
				$arraynew['data'][]= $arr;
			}
			$cri = new CDbCriteria();
			$cri->condition ='id="'.$id.'"';
			$profile = $profile->findAll($cri);
			foreach ($profile as $va)
			{
				$arraynew['data']['renwenContent'] =CHtml::value($va, 'content');
			}
			echo json_encode($arraynew);
		}else {
			$array =array(
				'code'=>0,
				'msg'=>'该条数据不存在',
			);
			echo json_encode($array);
		}
	}
}